package com.daxue.ormprovideservice.controller;

import lombok.Builder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.UUID;

/**
 * @author daxue0929
 * @date 2022/12/29
 */

@RestController
@Slf4j
public class HelloController {

    @GetMapping("/getUser")
    public User getUser() {
        User user = User.builder()
            .id("user-" + UUID.randomUUID().toString().replaceAll("-", ""))
            .name("daxue")
            .build();
        log.info("HelloController getUser: {}", user.toString());
//        throw new NullPointerException();//模拟一次服务发生了内部错误。
        return user;
    }


    @Data
    @Builder
    static class User {
        public String id;
        public String name;
    }
}
